//
//  RegisterAPIManger.m
//  FindJob
//
//  Created by 233 on 16/3/1.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "RegisterAPIManger.h"
#import "NetWorkingConfig.h"
#import "UserModel.h"
@implementation RegisterAPIManger
//- (void)startRegisterRequestParameter:(NSDictionary *)parameter responds:(void (^)(NetworkingStatus))respondsBlock{
//    
//    [self startRequestURL:kRegister parameters:parameter success:^(id respondsObj) {
//        NetworkingStatus status = [self handleResponds:respondsObj];
//        if (respondsBlock) {
//            respondsBlock(status);
//        }
//    } failure:^(NSError *error) {
//        if (respondsBlock) {
//            respondsBlock(NetworkingStatusTimeout);
//        }else{
//            respondsBlock(NetworkingStatusError);
//        }
//    } timeout:10.0f];
//    
//}
//#pragma mark *** private ***
//- (NetworkingStatus )handleResponds:(id)responds{
//    NetworkingStatus status;
//    NSInteger resultCode = [responds[@"resultCode"] integerValue];
//    if (resultCode == 0) {
//        status = NetworkingStatusSuccess;
//    }else{
//        status = NetworkingStatusError;
//    }
//    return status;
//}

- (void)startRegisterRequestParameter:(NSDictionary *)parameter responds:(void (^)(RespondsStatus, NSString *))respondsBlock{
    [self startRequestURL:kRegisterURL parameters:parameter success:^(id respondsObj) {
        NSInteger resultCode = [respondsObj[@"resultCode"] integerValue];
        NSString *resultDesc = respondsObj[@"resultDesc"];
        RespondsStatus status;
        if (resultCode == 0) {
            status = RespondsStatusSuccess;
            [UserModel shareUserModel].personID = respondsObj[@"resumePesonalId"];
            
        }else{
            status = RespondsStatusDataError;
        }
        if (respondsBlock) {
            respondsBlock(status,resultDesc);
        }
        
    } failure:^(NSError *error) {
        if (respondsBlock) {
            respondsBlock(RespondsStatusNotworkingError,@"网络错误");
        }
        
    } timeout:30.f];
}
@end
